package p2;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.swing.JFileChooser;

import generic.genetic.GeneticAlgorithm;
import generic.genetic.Population;
import generic.genetic.chromosome.Chromosome;
import generic.genetic.chromosome.PermutationChromosome;
import p2.genetic.HospitalDistributionChromosome;
import p2.view.MainFrame;

public class P2 {          
	            
	
	public static void main(String[] args){
		
			
		MainFrame mf = new MainFrame();
		mf.setVisible(true);
	
		/*
		String pathfile = System.getProperty("user.dir") + "/data";
		HospitalMatrixLoader hml12 = new HospitalMatrixLoader(pathfile+"/tai12.dat");
		HospitalMatrixLoader hml15 = new HospitalMatrixLoader(pathfile+"/tai15.dat");
		HospitalMatrixLoader hml30 = new HospitalMatrixLoader(pathfile+"/tai30.dat");
		
		Chromosome c12 = new HospitalDistributionChromosome(hml12.flow, hml12.distance);
		Population p12 = new Population(100,c12);
		GeneticAlgorithm ga12 = new GeneticAlgorithm(p12);
		ga12.setCrossover_method(1);
		ga12.setMutation_method(3);
		
		Chromosome c15 = new HospitalDistributionChromosome(hml15.flow, hml15.distance);
		Population p15 = new Population(100,c15);
		GeneticAlgorithm ga15 = new GeneticAlgorithm(p15);
		ga15.setCrossover_method(1);
		ga15.setMutation_method(3);
		
		Chromosome c30 = new HospitalDistributionChromosome(hml30.flow, hml30.distance);
		Population p30 = new Population(100,c30);
		GeneticAlgorithm ga30 = new GeneticAlgorithm(p30);
		ga30.setCrossover_method(1);
		ga30.setMutation_method(3);
		
		System.out.println("12 unidades");
		for (int i=0;i<20;i++){
			ga12.run();
			System.out.println(ga12.getBestChromosome());
		}
		
		System.out.println("15 unidades");
		for (int i=0;i<20;i++){
			ga15.run();
			System.out.println(ga15.getBestChromosome());
		}
		
		System.out.println("30 unidades");
		for (int i=0;i<20;i++){
			ga30.run();
			System.out.println(ga30.getBestChromosome());
		}
		*/
	}
}
